import axios from '~/plugins/axios'

const footer = {
  state: {
    footer: [],
    website: {}
  },

  mutations: {
    SET_FOOTER (state, payload) {
      state.footer = payload
    },

    SET_WEBSITE (state, payload) {
      state.website = payload
    }
  },

  actions: {
    async nuxtServerInit ({commit}) {
      const [{data: footer}, {data: website}] = await Promise.all([
        axios.get(`/findFooter`).then(data => data.data),
        axios.get(`/siteList`).then(data => data.data)
      ])
      commit('SET_FOOTER', footer)
      commit('SET_WEBSITE', website)
    }
  }
}

export default footer
